"""
函数：insert_img
实现：获取当前运行的路径，拼装截图名称，并生成截图
参数：
    driver: 浏览器对象
    name：截图名
返回值：无
"""
from selenium import webdriver
from time import sleep
import os


def insert_img(driver, name):
    dir_name = os.path.dirname(__file__)
    # print(dir_name)
    up_dir_name = os.path.dirname(dir_name)
    # print(up_dir_name)
    img_name = rf'{up_dir_name}\reports\screenshots\{name}.png'
    # print(img_name)
    driver.get_screenshot_as_file(img_name)


# if __name__ == '__main__':
#     name = 'baidu'
#     url = r'https://www.baidu.com/'
#     driver = webdriver.Chrome(options=options)
#     driver.get(url)
#
#     insert_img(driver, name)
#
#     driver.quit()
